import { configureStore, combineReducers } from '@reduxjs/toolkit';
import { TypedUseSelectorHook, useSelector, useDispatch } from 'react-redux';

import global from './global';
import screen from './screen';
import user from './user';

const reducer = combineReducers({
  global,
  screen,
  user,
});

export const store = configureStore({
  reducer,
});

export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;

export const selectGlobal = (state: RootState) => state.global;
export const selectScreen = (state: RootState) => state.screen;
export const selectUser = (state: RootState) => state.user;

// export const useAppDispatch = () => useDispatch<AppDispatch>();
// export const useAppSelector: UseSelector = useSelector;
export default store;
